Root Zanli
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
o5t6x7pgljbm
/
www
/
admin
/
app
/
Models
/
Filename :
CustomField.php
back
Copy
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\Casts\Attribute; use Config; use Illuminate\Support\Carbon; class CustomField extends Model { use SoftDeletes; protected $table = 'custom_fields'; protected $primaryKey = 'custom_field_id'; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'entity_type', 'entity_id', 'field_type', 'field_name', 'field_label', 'field_meta', 'field_help_text', 'field_data_regex_validation', 'data', 'created_at', 'updated_at', 'deleted_at' ]; /** * The attributes that should be hidden for arrays. * * @var array */ protected $hidden = [ 'deleted_at' ]; public function cloneCustomField($newEntityType, $newEntityId){ $excludeColumns = ['created_at','updated_at']; $clone = $this->replicate(); // $clone->created_by = null; $clone->created_at = null; $clone->updated_at = null; //set new values $clone->entity_type = $newEntityType; $clone->entity_id = $newEntityId; $clone->created_at = Carbon::now(); $clone->updated_at = Carbon::now(); $clone->save(); return $clone; } }